home *** CD-ROM | disk | FTP | other *** search
- class soundManage.SoundManage
- {
- var isMusicPlay;
- var isSoundPlay;
- var soundArray = new Array();
- var musicArray = new Array();
- function SoundManage()
- {
- _root.createEmptyMovieClip("mysound_mc",_root.getNextHighestDepth());
- _root.createEmptyMovieClip("mymusic_mc",_root.getNextHighestDepth());
- this.soundArray[0] = new Array();
- this.soundArray[1] = new Array();
- this.soundArray[2] = new Array();
- this.musicArray[0] = new Array();
- this.musicArray[1] = new Array();
- this.musicArray[2] = new Array();
- this.addMusic("main_s");
- if(this.isMusicPlay == undefined)
- {
- this.isMusicPlay = true;
- this.playMusic("main_s",9999);
- }
- if(this.isSoundPlay == undefined)
- {
- this.isSoundPlay = true;
- }
- }
- function addSound()
- {
- switch(arguments.length)
- {
- case 1:
- this.soundArray[0].push(arguments[0]);
- _root.mysound_mc.createEmptyMovieClip(arguments[0] + "_sound",_root.mysound_mc.getNextHighestDepth());
- var _loc4_ = new Sound(_root.mysound_mc[arguments[0] + "_sound"]);
- _loc4_.attachSound(arguments[0]);
- this.soundArray[1].push(_loc4_);
- this.soundArray[2].push(100);
- break;
- case 2:
- if(arguments[1] > 100)
- {
- arguments[1] = 100;
- }
- else if(arguments[1] < 0)
- {
- arguments[1] = 0;
- }
- this.soundArray[0].push(arguments[0]);
- _root.mysound_mc.createEmptyMovieClip(arguments[0] + "_sound",_root.mysound_mc.getNextHighestDepth());
- _loc4_ = new Sound(_root.mysound_mc[arguments[0] + "_sound"]);
- _loc4_.attachSound(arguments[0]);
- _loc4_.setVolume(arguments[1]);
- this.soundArray[1].push(_loc4_);
- this.soundArray[2].push(arguments[1]);
- }
- }
- function addMusic()
- {
- switch(arguments.length)
- {
- case 1:
- this.musicArray[0].push(arguments[0]);
- _root.mymusic_mc.createEmptyMovieClip(arguments[0] + "_sound",_root.mymusic_mc.getNextHighestDepth());
- var _loc4_ = new Sound(_root.mymusic_mc[arguments[0] + "_sound"]);
- _loc4_.attachSound(arguments[0]);
- this.musicArray[1].push(_loc4_);
- this.musicArray[2].push(100);
- break;
- case 2:
- if(arguments[1] > 100)
- {
- arguments[1] = 100;
- }
- else if(arguments[1] < 0)
- {
- arguments[1] = 0;
- }
- this.musicArray[0].push(arguments[0]);
- _root.mymusic_mc.createEmptyMovieClip(arguments[0] + "_sound",_root.mymusic_mc.getNextHighestDepth());
- _loc4_ = new Sound(_root.mymusic_mc[arguments[0] + "_sound"]);
- _loc4_.attachSound(arguments[0]);
- _loc4_.setVolume(arguments[1]);
- this.musicArray[1].push(_loc4_);
- this.musicArray[2].push(arguments[1]);
- }
- }
- function stopSound()
- {
- this.isSoundPlay = false;
- var _loc2_ = 0;
- while(_loc2_ <= this.soundArray[1].length)
- {
- this.soundArray[1][_loc2_].setVolume(0);
- _loc2_ = _loc2_ + 1;
- }
- }
- function stopMusic()
- {
- this.isMusicPlay = false;
- var _loc2_ = 0;
- while(_loc2_ <= this.musicArray[1].length)
- {
- this.musicArray[1][_loc2_].setVolume(0);
- _loc2_ = _loc2_ + 1;
- }
- }
- function returnSound()
- {
- this.isSoundPlay = true;
- var _loc2_ = 0;
- while(_loc2_ < this.soundArray[1].length)
- {
- this.soundArray[1][_loc2_].setVolume(this.soundArray[2][_loc2_]);
- _loc2_ = _loc2_ + 1;
- }
- }
- function returnMusic()
- {
- this.isMusicPlay = true;
- var _loc2_ = 0;
- while(_loc2_ < this.musicArray[1].length)
- {
- this.musicArray[1][_loc2_].setVolume(this.musicArray[2][_loc2_]);
- _loc2_ = _loc2_ + 1;
- }
- }
- function playSound()
- {
- if(this.isSoundPlay == true)
- {
- switch(arguments.length)
- {
- case 1:
- var _loc3_ = 0;
- while(_loc3_ <= this.soundArray[0].length)
- {
- if(this.soundArray[0][_loc3_] == arguments[0])
- {
- this.soundArray[1][_loc3_].start(0,1);
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- break;
- case 2:
- _loc3_ = 0;
- while(_loc3_ <= this.soundArray[0].length)
- {
- if(this.soundArray[0][_loc3_] == arguments[0])
- {
- this.soundArray[1][_loc3_].start(0,arguments[1]);
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- break;
- case 3:
- _loc3_ = 0;
- while(_loc3_ <= this.soundArray[0].length)
- {
- if(this.soundArray[0][_loc3_] == arguments[0])
- {
- this.soundArray[1][_loc3_].setVolume(arguments[2]);
- this.soundArray[1][_loc3_].start(0,arguments[1]);
- this.soundArray[1][_loc3_].setVolume(this.soundArray[2][_loc3_]);
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- }
- }
- function playMusic()
- {
- if(this.isMusicPlay == true)
- {
- switch(arguments.length)
- {
- case 1:
- var _loc3_ = 0;
- while(_loc3_ <= this.musicArray[0].length)
- {
- if(this.musicArray[0][_loc3_] == arguments[0])
- {
- this.musicArray[1][_loc3_].start(0,1);
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- break;
- case 2:
- _loc3_ = 0;
- while(_loc3_ <= this.musicArray[0].length)
- {
- if(this.musicArray[0][_loc3_] == arguments[0])
- {
- this.musicArray[1][_loc3_].start(0,arguments[1]);
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- break;
- case 3:
- _loc3_ = 0;
- while(_loc3_ <= this.musicArray[0].length)
- {
- if(this.musicArray[0][_loc3_] == arguments[0])
- {
- this.musicArray[1][_loc3_].setVolume(arguments[2]);
- this.musicArray[1][_loc3_].start(0,arguments[1]);
- this.musicArray[1][_loc3_].setVolume(this.musicArray[2][_loc3_]);
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- }
- }
- }
-